//
// Created by sjjmw on 3/24/2022.
//
#include "iostream"
#include "vector"
#include "list"
#include "algorithm"
#include "string"
#include "unordered_map"
#include "cmath"
#include<iomanip>
#include "string"
#include "map"
#include "list"
struct Pos{
    int x;
    int y;
};
struct State{
    int x;
    int y;
    char dir;
    int depth=0;
//    std::vector<Pos> walkeds;
    State*last= nullptr;
    bool walked(int x1,int y1){
        State*last1=last;
        while (last1){
            if(x1==last1->x&&y1==last1->y){
                return true;
            }
            last1=last1->last;
        }
        return false;
    }
};
struct Sol{
    int h;
    int w;
    std::vector<std::string> mat;
    std::vector<std::vector<char>> walked;
    std::list<State> queue;
    std::list<State> out_queue;
    bool can_stay(int x,int y){
        if(x<0||x>=w||y<0||y>=h){
            return false;
        }
        if(mat[y][x]=='1'){
            return false;
        }
        return true;
    }
    void try_walk(int x,int y,State*front,char dir){
        if(can_stay(x,y)&&!walked[y][x]){
            walked[y][x]=1;
            State cpy=*front;
            cpy.x=x;cpy.y=y;
            cpy.dir=dir;
//            cpy.walkeds.push_back({front->x, front->y});
            cpy.last=front;
            cpy.depth++;
            queue.push_back(cpy);
        }
    }
    void handle(
            int h1,int w1
            ){
        h=h1;w=w1;
        mat.reserve(h);
        std::vector<char> line(w);
        int ans=0;
        std::string str;
        std::getline(std::cin,str);
        for(int i=0;i<h;i++){
            std::getline(std::cin,str);
            walked.push_back(line);
            mat.push_back(str);
        }
//        std::cout<<std::endl;
        queue.push_back({0,0});
        State*final= nullptr;
        while(!queue.empty()){
            out_queue.splice(out_queue.begin(),queue,queue.begin());
            auto& front=out_queue.front();
            if(front.x==w-1&&front.y==h-1){
                final=&front;

                            std::cout<<final->depth<<std::endl;
                break;
            }
//            int x=front.x+1;
//            int y=front.y;
//

            try_walk(front.x,front.y+1,&front,'D');

            try_walk(front.x-1,front.y,&front,'L');

            try_walk(front.x+1,front.y,&front,'R');
            try_walk(front.x,front.y-1,&front,'U');
        }
        std::vector<char> stack;
        while (final){
            stack.push_back(final->dir);
            final=final->last;
        }
//        printf("%d\n",stack.size()-1);
        for(int i=stack.size()-2;i>=0;i--){
            printf("%c",stack[i]);
        }
        ;
    }
};
int main(){
    int a,b,c;
//    float a,b,c,d;
    int e;
    while(std::cin>>a>>b){
        Sol().handle(a,b);
    }

    return 0;
}